<template>
  <div v-if="loading" class="com-global-loading">
    <img src="https://cdn.wangyabin.top/YBWeb/loading/loading.gif" alt="">
  </div>
</template>

<script lang="ts">
import { Vue, Watch, Component } from 'vue-property-decorator'
import { State } from 'vuex-class'
import { removeLoading } from '@/utils'

@Component({
  name: 'ComGlobalLoading'
})
export default class ComGlobalLoadMore extends Vue {
  @State(state => state.app.loading) loading!:boolean

  @Watch('loading')
  loadingChange (loading: boolean) {
    document.body.style.overflow = loading ? 'hidden' : 'visible'
  }

  mounted () {
    removeLoading()
  }
}
</script>

<style lang="less" scoped>
.com-global-loading {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgb(224, 245, 254);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  flex-direction: column;
  opacity: 0.6;

  img {
    width: 400px;
    height: 400px;
  }
}

</style>
